package 面向对象.testSeven;

import java.io.*;

public class CopyFile {
    public static void main(String[] args) {
        FileInputStream fin;
        FileOutputStream fout;
        int ch;                                     //声明变量用来读入用户输入字符
        try {
            //以标准输入设备为输入文件
            fin = new FileInputStream(FileDescriptor.in);
            //以 为输出文件
            fout = new FileOutputStream("D:\\Program Files\\JetBrains\\IntelliJ IDEA 2021.2.3\\MyProject_JAVA\\IdeaProjects\\idea-cu\\src\\面向对象\\testSeven\\copyfile.txt");
            System.out.println("请输入一行内容:");
            while ((ch = fin.read()) != 10)    //反复读输入流，直到输入回车符为止,ascll码中10为硬回车，13为软回车，即换行
                fout.write(ch);
                fin.close();
                fout.close();                   //关闭输入和输出流
                System.out.println("Success");
        }catch (FileNotFoundException e){
            System.out.println("找不到文件。");
        }catch (IOException e){
            System.out.println("error in input stream");
        }
    }
}
